#include "cutting.hpp"

/**
 * @brief 构造函数
 */
cutting::cutting(std::string ip, std::vector<std::vector<int>> regions)
{
    int size = 5 * 1024 * 1024;
    rbuf.set(size);

    std::string url = "rtsp://admin:avs12.345@" + ip + "/H.264/ch1/main/av_stream";
    demux.set(url, &rbuf, ip);
    demux.start();

    mux.set(&rbuf, ip);
    mux.start();

    dec.set(&rbuf, ip, regions);
    dec.mux_set(&mux);
    dec.start();

#if RAW_VIDEO_SAVE
    raw.set(&rbuf, ip);
    raw.start();
#endif
}

/**
 * @brief 析构函数
 */
cutting::~cutting()
{
#if RAW_VIDEO_SAVE
    raw.stop();
#endif
    mux.stop();
    dec.stop();
    demux.stop();
}
